﻿using Manager;
using Manager.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using UboxUI;
using ClassLibrary;
using Product;

namespace Manager
{
    public partial class FrmNewsCreate : FrmFather
    {
        public FrmNewsCreate()
        {
            InitializeComponent();
            this.LblTitle.Text = this.Text;
            this.LblTitle2.Text = LblTitle.Text;
            this.BtnClose.Left = this.Width - this.BtnClose.Width - 10;
            this.BtnNarrow.Left = this.BtnClose.Left - this.BtnNarrow.Width - 10;
            this.panel1.Top = 0;
            this.panel2.Top = this.panel1.Height;
        }
        string conn = Settings.Default.strConn;

        #region 按鈕的樣式

        private void button2_MouseEnter(object sender, EventArgs e)
        {
            this.button2.FlatAppearance.BorderSize = 0;
            this.button2.ForeColor = Color.White;

        }

        private void button2_MouseLeave(object sender, EventArgs e)
        {
            this.button2.FlatAppearance.BorderSize = 1;
            this.button2.ForeColor = Color.Black;
        }

        private void button3_MouseEnter(object sender, EventArgs e)
        {
            this.button3.FlatAppearance.BorderSize = 0;
            this.button3.ForeColor = Color.White;
        }

        private void button3_MouseLeave(object sender, EventArgs e)
        {
            this.button3.FlatAppearance.BorderSize = 1;
            this.button3.ForeColor = Color.Black;
        }
        #endregion

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Product.news n = new Product.news();
            n.news_title = this.textBox1.Text;
            n.news_date = this.dateTimePicker1.Value;
            n.news_content = this.richTextBox1.Text;
            n.manager_id = login.managerID;
            n.news_visible = true;
            UboxDataClassesDataContext db = new UboxDataClassesDataContext(conn);
            db.news.InsertOnSubmit(n);
            db.SubmitChanges();
            MessageBox.Show("新增成功");
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Text = "I-DY火線上陣!";
            richTextBox1.Text = "各位尊貴的會員們，最新的I點維手機已經上線了，我們熱切期待您的開箱文!您的分享就是我們最大的動力。";
        }
    }
}
